package com.ag.wsq.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

import com.ag.bean.TbDetailShift;
import com.ag.bean.TbDuty;
import com.ag.bean.TbSched;
import com.ag.bean.TbSchedId;
import com.ag.bean.TbUser;
import com.ag.common.BaseAction;
import com.ag.wsq.service.impl.SchedBaseServiceImpl;
/*
 * @author 王淑其
 */

public class AddSchedAction extends BaseAction {
	
	private static final Logger logger = Logger.getLogger(AddSchedAction.class);
	private SchedBaseServiceImpl schedBaseServiceImpl;
	private String id;
	private String UId1;
	private String dsName1;
	private String duId1;
	private String scTime;
	private String ajaxRST="0";
	
	/*
	 * 保存排班人员
	 * @return
	 */
	public String saveSched() throws Exception{
		
			if(scTime != null && scTime.length()>0){
				TbSched sched = new TbSched();
				TbSchedId schedId = new TbSchedId();
				SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
				Date myDate = null;
				try {
					myDate = dateFormat.parse(scTime);
					System.out.println("-----myDate:"+myDate);
				} catch (Exception e) {
					e.printStackTrace();
				}
                schedId.setScTime(myDate);
                schedId.setDsName(dsName1);
                schedId.setDuId(duId1);
                schedId.setUId(UId1);
                sched.setId(schedId);
				
				schedBaseServiceImpl.saveOrUpdateSched(sched);
				
System.out.println("-------------save stop----------------");		
				this.ajaxRST="1";
				System.out.println("save sched ok!");
			} else {
				System.out.println("can not to be null");
			}

		return "saveSchedOk";
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

	public SchedBaseServiceImpl getSchedBaseServiceImpl() {
		return schedBaseServiceImpl;
	}

	public void setSchedBaseServiceImpl(SchedBaseServiceImpl schedBaseServiceImpl) {
		this.schedBaseServiceImpl = schedBaseServiceImpl;
	}

	public String getUId1() {
		return UId1;
	}

	public void setUId1(String uId1) {
		UId1 = uId1;
	}

	public String getDuId1() {
		return duId1;
	}

	public void setDuId1(String duId1) {
		this.duId1 = duId1;
	}

	public String getScTime() {
		return scTime;
	}

	public void setScTime(String scTime) {
		this.scTime = scTime;
	}

	public String getAjaxRST() {
		return ajaxRST;
	}

	public void setAjaxRST(String ajaxRST) {
		this.ajaxRST = ajaxRST;
	}

	public String getDsName1() {
		return dsName1;
	}

	public void setDsName1(String dsName1) {
		this.dsName1 = dsName1;
	}
	
}
